package com.example.demo2.controller;

import com.example.demo2.entity.Person;
import com.example.demo2.service.PersonService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Administrator
 */
@Controller
@RequestMapping("/persons")
public class PersonHtml {
    @Resource
    private PersonService personService;


    @RequestMapping("/all")
    public String findAllPerson(ModelMap map) {
        List<Person> people = personService.findAllPerson();
        map.addAttribute("person", people);
        return "person";
    }

    @RequestMapping("/error")
    public String error(ModelMap map) {
        List<Person> people = personService.findAllPerson();
        map.addAttribute("person", people);
        return "error404";
    }
}
